package com.gm.wholesale.module.report.model;

import android.util.ArrayMap;

import com.gm.commonlib.base.baseBean.BasePageData;
import com.gm.commonlib.base.baseBean.DataResp;
import com.gm.commonlib.base.baseView.IBaseView;
import com.gm.commonlib.network.BaseHttpObserver;
import com.gm.commonlib.network.HttpClient;
import com.gm.commonlib.network.HttpServicesHolder;
import com.gm.wholesale.module.report.api.IReportApi;
import com.gm.wholesale.module.report.bean.CustormReportBean;
import com.gm.wholesale.module.report.bean.GoodReportBean;
import com.gm.wholesale.module.report.bean.ReportCustomBean;
import com.gm.wholesale.module.report.bean.ReportGoodBean;
import com.gm.wholesale.module.report.bean.SaleReportBean;

import io.reactivex.Observable;
import retrofit2.http.Body;

public class ReportModel {
    public static void getReportCustomerSKU(IBaseView iBaseView,
                                            long customerID,
                                            BaseHttpObserver<BasePageData<ReportGoodBean>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReportApi, BasePageData<ReportGoodBean>>() {
            @Override
            public Observable<BasePageData<ReportGoodBean>> getHttpObservable(IReportApi instance) {
                return instance.getReportCustomerSKU(customerID);
            }
        }, observer);
    }


    public static void getReportSKU(IBaseView iBaseView,
                                    long customerID,
                                    BaseHttpObserver<BasePageData<ReportCustomBean>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReportApi, BasePageData<ReportCustomBean>>() {
            @Override
            public Observable<BasePageData<ReportCustomBean>> getHttpObservable(IReportApi instance) {
                return instance.getReportSku(customerID);
            }
        }, observer);
    }


    // todo 获取销售报表
    public static void getSaleReport(IBaseView iBaseView,
                                     ArrayMap<String, Object> data,
                                     BaseHttpObserver<DataResp<SaleReportBean>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReportApi, DataResp<SaleReportBean>>() {
            @Override
            public Observable<DataResp<SaleReportBean>> getHttpObservable(IReportApi instance) {
                return instance.getSaleReport(data);
            }
        }, observer);
    }


    public static void getCustomerReport(IBaseView iBaseView,
                                         @Body ArrayMap<String, Object> queryData,
                                         BaseHttpObserver<BasePageData<CustormReportBean>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReportApi, BasePageData<CustormReportBean>>() {
            @Override
            public Observable<BasePageData<CustormReportBean>> getHttpObservable(IReportApi instance) {
                return instance.getCustomerReport(queryData);
            }
        }, observer);
    }


    public static void getGoodReport(IBaseView iBaseView,
                                     @Body ArrayMap<String, Object> queryData,
                                     BaseHttpObserver<BasePageData<GoodReportBean>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IReportApi, BasePageData<GoodReportBean>>() {
            @Override
            public Observable<BasePageData<GoodReportBean>> getHttpObservable(IReportApi instance) {
                return instance.getSKUReport(queryData);
            }
        }, observer);
    }

}
